package com.timmy.google_play.holder;

import android.view.View;
import android.widget.LinearLayout;

import com.timmy.google_play.R;
import com.timmy.google_play.base.BaseHolder;
import com.timmy.google_play.utils.UIUtils;

import butterknife.BindView;

/**
 * Created by Timmy on 2016/12/11.
 */

 public class LoadMoreHolder extends BaseHolder<Integer> {

    public static final int LOADMORE_LOADING = 0;
    public static final int LOADMORE_ERROR   = 1;
    public static final int LOADMORE_NONE    = 2;

    @BindView(R.id.item_loadmore_container_loading)
    LinearLayout mItemLoadmoreContainerLoading;
    @BindView(R.id.item_loadmore_container_retry)
    LinearLayout mItemLoadmoreContainerRetry;

    /**
     * 决定loadmoreHolder 所能提供的视图是什么
     *
     * @return
     */
    @Override
    protected View initHolderVIew() {
        return View.inflate(UIUtils.getContext(), R.layout.item_load_more, null);
    }

    /**
     * 数据和视图的绑定
     * 根据int数去决定隐藏或者显示
     */
    @Override
    protected void refreshHolderView(Integer satae) {

        mItemLoadmoreContainerLoading.setVisibility(View.GONE);
        mItemLoadmoreContainerRetry.setVisibility(View.GONE);

        switch (satae) {
            case LOADMORE_LOADING:      //加载更多状态

                mItemLoadmoreContainerLoading.setVisibility(View.VISIBLE);

                break;
            case LOADMORE_ERROR:        //加载失败 状态
                mItemLoadmoreContainerRetry.setVisibility(View.VISIBLE);

                break;
            case LOADMORE_NONE:         //没有加载更多状态
                break;
        }

    }
}
